<template>
  <div class="challenge-page">
    
    <!-- 标签页导航 -->
    <div class="tabs-nav">
      <div class="tab-item" :class="{ active: activeTab === 'home' }" @click="switchTab('home')">
        挑战首页
      </div>
      <div class="tab-item" :class="{ active: activeTab === 'ranking' }" @click="switchTab('ranking')">
        排行榜
      </div>
    </div>
    
    <!-- 内容区域过渡动画 -->
    <transition name="content-fade" mode="out-in">
      <div class="challenge-content" :key="activeTab">
      <!-- 左侧功能导航 -->
      <div class="left-navigation">
        <div v-if="activeTab === 'home'">
          <div class="daily-challenge">
            <div class="challenge-header">
              <span class="clock-icon">⏰</span>
              <h2>每日挑战</h2>
            </div>
            <div class="challenge-status">
              <p>今日 5 题未完成</p>
            </div>
          </div>
          
          <div class="theme-adventure">
            <div class="adventure-header">
              <span class="adventure-icon">🗺️</span>
              <h2>主题闯关</h2>
            </div>
            <div class="adventure-progress">
              <div class="progress-info">
                <span>12 大关</span>
                <span>已答题数 / 总题数</span>
              </div>
              <div class="progress-bars">
                <div class="progress-item" v-for="i in 12" :key="i">
                  <div class="progress-bar">
                    <div class="progress-fill" :style="{ width: i <= 5 ? '100%' : i <= 8 ? '60%' : '0%' }"></div>
                  </div>
                  <span class="stage-number">{{ i }}</span>
                  <span class="reward-badge" v-if="i <= 3">🎁</span>
                </div>
              </div>
            </div>
          </div>
          
          <div class="weekly-ranking">
            <div class="ranking-header">
              <span class="ranking-icon">🏆</span>
              <h2>周排行榜</h2>
            </div>
            <div class="ranking-content">
              <p>正确率 × 答题速度排名</p>
              <div class="top-rankers">
                <div class="rank-item" v-for="(ranker, index) in displayedRanking" :key="index">
                  <span class="rank-number">{{ ranker.rank }}</span>
                  <span class="rank-name">{{ ranker.username }}</span>
                  <span class="rank-score">{{ ranker.total_score }}</span>
                </div>
              </div>
            </div>
          </div>
        </div>
        
        <!-- 排行榜标签页 - 左侧内容 -->
        <div v-if="activeTab === 'ranking'" class="ranking-sidebar">
          <div class="ranking-filters">
            <h3>排行榜筛选</h3>
            <div class="filter-group">
              <button 
                class="filter-btn" 
                :class="{ active: rankingPeriod === 'week' }"
                @click="changeRankingPeriod('week')"
              >
                周榜
              </button>
              <button 
                class="filter-btn" 
                :class="{ active: rankingPeriod === 'month' }"
                @click="changeRankingPeriod('month')"
              >
                月榜
              </button>
              <button 
                class="filter-btn" 
                :class="{ active: rankingPeriod === 'total' }"
                @click="changeRankingPeriod('total')"
              >
                总榜
              </button>
            </div>
          </div>
          
          <div class="user-rank-info">
            <h3>我的排名</h3>
            <div class="my-rank-item" v-if="userRank">
              <div class="rank-number" :class="getRankClass(userRank.rank)">{{ userRank.rank }}</div>
              <div class="my-rank-detail">
                <div class="avatar">👤</div>
                <div class="username">{{ userRank.username || '环保爱好者' }}</div>
                <div class="score">得分: {{ userRank.total_score || 0 }}</div>
                <div class="rank-info" v-if="userRank.accuracy_rate">
                  <span>正确率: {{ (userRank.accuracy_rate * 100).toFixed(1) }}%</span>
                  <span v-if="userRank.average_time">平均用时: {{ userRank.average_time }}s</span>
                </div>
              </div>
            </div>
            <div class="no-data" v-else>暂无排名数据</div>
          </div>
        </div>
      </div>
      
      <!-- 主互动区 -->
      <div class="main-interaction">
        <div class="interaction-content">
          <!-- 挑战首页内容 -->
          <div v-if="activeTab === 'home'">
            <div class="welcome-section">
              <div class="welcome-header">
                <div class="welcome-text">
                  <h2>欢迎来到低碳知识挑战</h2>
                  <p>通过答题挑战提升你的环保知识，解锁低碳骑士皮肤，赢取丰厚奖励！</p>
                </div>
                <div class="user-challenge-section">
                  <div class="user-profile">
                    <span class="avatar">👤</span>
                    <span class="username">环保爱好者</span>
                  </div>
                  <div class="user-points">
                    <span class="points-icon">💰</span>
                    <span class="points-value">2450</span>
                  </div>
                  <button @click="startRandomQuiz" class="start-challenge-btn">
                    开始挑战
                  </button>
                  <button @click="$router.push('/level-list')" class="level-list-btn">
                    查看关卡列表
                  </button>
                </div>
              </div>
            </div>
            
            <div class="challenge-features">
              <div class="feature-card">
                <div class="feature-icon">📈</div>
                <h3>KT-RL 动态难度</h3>
                <p>根据你的答题表现智能调整题目难度</p>
              </div>
              
              <div class="feature-card">
                <div class="feature-icon">🛡️</div>
                <h3>12大关卡</h3>
                <p>完成所有关卡解锁专属低碳骑士皮肤</p>
              </div>
              
              <div class="feature-card">
                <div class="feature-icon">🏆</div>
                <h3>周排行榜</h3>
                <p>与全国用户比拼正确率和答题速度</p>
              </div>
            </div>
            
            <div class="challenge-stats">
              <div class="stat-card">
                <h3>今日挑战</h3>
                <p class="stat-value">5/5</p>
                <p class="stat-label">题目</p>
              </div>
              
              <div class="stat-card">
                <h3>本周排名</h3>
                <p class="stat-value">24</p>
                <p class="stat-label">名次</p>
              </div>
              
              <div class="stat-card">
                <h3>累计积分</h3>
                <p class="stat-value">2450</p>
                <p class="stat-label">碳积分</p>
              </div>
            </div>
          </div>
          
          <!-- 排行榜页面内容 -->
          <div v-if="activeTab === 'ranking'" class="ranking-main-content">
            <div class="ranking-header-section">
              <h2>{{ getRankingTitle() }}排行榜</h2>
              <p>根据用户的正确率和答题速度综合排名</p>
            </div>
            
            <!-- 排行榜前三名特殊展示 -->
            <div class="top-three-container">
              <div class="rank-item second-place">
                <div class="medal">🥈</div>
                <div class="avatar">👤</div>
                <div class="username">{{ leaderboardData.length > 1 ? leaderboardData[1].username : '第二名' }}</div>
                <div class="score">{{ leaderboardData.length > 1 ? leaderboardData[1].total_score : '--' }}</div>
              </div>
              
              <div class="rank-item first-place">
                <div class="medal">🥇</div>
                <div class="avatar">👤</div>
                <div class="username">{{ leaderboardData.length > 0 ? leaderboardData[0].username : '第一名' }}</div>
                <div class="score">{{ leaderboardData.length > 0 ? leaderboardData[0].total_score : '--' }}</div>
              </div>
              
              <div class="rank-item third-place">
                <div class="medal">🥉</div>
                <div class="avatar">👤</div>
                <div class="username">{{ leaderboardData.length > 2 ? leaderboardData[2].username : '第三名' }}</div>
                <div class="score">{{ leaderboardData.length > 2 ? leaderboardData[2].total_score : '--' }}</div>
              </div>
            </div>
            
            <!-- 排行榜列表 -->
            <div class="ranking-list">
              <div class="ranking-list-header">
                <div class="rank-col">排名</div>
                <div class="user-col">用户</div>
                <div class="correct-col">正确率</div>
                <div class="time-col">平均用时</div>
                <div class="score-col">总分</div>
              </div>
              
              <div 
                class="ranking-list-item" 
                v-for="(item, index) in leaderboardData" 
                :key="index"
                :class="{ 'my-rank': userRank && item.username === userRank.username }"
              >
                <div class="rank-col">{{ item.rank }}</div>
                <div class="user-col">
                  <span class="avatar">👤</span>
                  <span class="username">{{ item.username }}</span>
                </div>
                <div class="correct-col">{{ item.accuracy_rate ? (item.accuracy_rate * 100).toFixed(1) + '%' : '--' }}</div>
                <div class="time-col">{{ item.average_time ? item.average_time + 's' : '--' }}</div>
                <div class="score-col">{{ item.total_score || 0 }}</div>
              </div>
              
              <div class="no-data" v-if="leaderboardData.length === 0">暂无排行榜数据</div>
            </div>
          </div>
        </div>
      </div>
      
      <!-- 右侧信息激励区 -->
      <div class="right-info">
        <div v-if="activeTab === 'home'">
          <div class="personal-data" @click="$router.push('/user-stats')">
            <h3>个人数据</h3>
            <div class="data-item">
              <span>总答题数</span>
              <span>{{ userStats.total_answered || 128 }}</span>
            </div>
            <div class="data-item">
              <span>正确率</span>
              <span>{{ userStats.accuracy_rate ? userStats.accuracy_rate.toFixed(1) + '%' : '87%' }}</span>
            </div>
            <div class="data-item">
              <span>平均用时</span>
              <span>{{ userStats.average_time ? userStats.average_time + 's' : '42s' }}</span>
            </div>
          </div>
          
          <div class="popular-recommendations">
            <h3>热门推荐</h3>
            <div class="recommendation-item">
              <div class="recommendation-icon">🔥</div>
              <div class="recommendation-content">
                <h4>气候变化专题</h4>
                <p>最新挑战题目</p>
              </div>
            </div>
            
            <div class="recommendation-item">
              <div class="recommendation-icon">💡</div>
              <div class="recommendation-content">
                <h4>环保小贴士</h4>
                <p>每日环保知识</p>
              </div>
            </div>
          </div>
          
          <div class="point-redemption">
            <h3>积分兑换</h3>
            <div class="redemption-item">
              <div class="redemption-icon">🌳</div>
              <div class="redemption-content">
                <h4>植树公益</h4>
                <p>1000积分兑换</p>
              </div>
            </div>
            
            <div class="redemption-item">
              <div class="redemption-icon">🎁</div>
              <div class="redemption-content">
                <h4>低碳骑士皮肤</h4>
                <p>5000积分兑换</p>
              </div>
            </div>
          </div>
        </div>
        
        <!-- 排行榜标签页 - 右侧内容 -->
        <div v-if="activeTab === 'ranking'" class="ranking-right-info">
          <div class="ranking-rules">
            <h3>排名规则</h3>
            <ul>
              <li>根据用户的答题正确率和答题速度计算总分</li>
              <li>正确率占比60%，答题速度占比40%</li>
              <li>每周一00:00重置周榜数据</li>
              <li>每月1日00:00重置月榜数据</li>
            </ul>
          </div>
          
          <div class="ranking-rewards">
            <h3>排名奖励</h3>
            <div class="reward-tier">
              <div class="tier-icon">🥇</div>
              <div class="tier-info">
                <div class="tier-title">周榜冠军</div>
                <div class="tier-reward">1000积分 + 限定勋章</div>
              </div>
            </div>
            <div class="reward-tier">
              <div class="tier-icon">🥈</div>
              <div class="tier-info">
                <div class="tier-title">周榜亚军</div>
                <div class="tier-reward">800积分 + 限定勋章</div>
              </div>
            </div>
            <div class="reward-tier">
              <div class="tier-icon">🥉</div>
              <div class="tier-info">
                <div class="tier-title">周榜季军</div>
                <div class="tier-reward">500积分 + 限定勋章</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    </transition>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { useRouter } from 'vue-router'
import { 
  getLevelList,
  getUserStats,
  getLeaderboard,
  getRandomQuestion,
  getMyRank
} from '../api/challenge'

// 路由
const router = useRouter()

// 响应式数据
const dailyChallenge = ref<any | null>(null)
const themeProgress = ref<any[]>([])
const weeklyRanking = ref<any[]>([])
const challengeHistory = ref<any[]>([])
const userStats = ref<any>({})
// 标签页相关
const activeTab = ref('home')
// 排行榜相关
const leaderboardData = ref<any[]>([])
const userRank = ref<any | null>(null)
const rankingPeriod = ref('week')

// 计算属性 - 显示前3名排行榜
const displayedRanking = computed(() => {
  // 如果有真实数据，使用真实数据，否则使用默认数据
  if (weeklyRanking.value && weeklyRanking.value.length > 0) {
    return weeklyRanking.value.slice(0, 3);
  }
  // 默认数据
  return [
    { rank: 1, username: '环保达人', total_score: 98 },
    { rank: 2, username: '绿色先锋', total_score: 95 },
    { rank: 3, username: '低碳骑士', total_score: 92 }
  ];
})

// 开始随机题目挑战
const startRandomQuiz = async () => {
  try {
    // 获取随机题目
    const response: any = await getRandomQuestion()
    
    // 检查响应是否成功
    if (response && response.success && response.data) {
      // 将题目数据存储到本地存储中，以便在答题页面使用
      localStorage.setItem('randomQuestion', JSON.stringify(response.data))
      
      // 跳转到答题页面
      router.push('/random-quiz')
    } else {
      // 获取失败
      const message = response && response.message ? response.message : '获取随机题目失败'
      alert('获取随机题目失败: ' + message)
    }
  } catch (error: any) {
    console.error('[Challenge] 获取随机题目失败:', error)
    alert('获取随机题目失败: ' + (error.message || '未知错误'))
  }
}

// 方法
const loadDailyChallenge = async () => {
  try {
    const response = await getLevelList()
    dailyChallenge.value = response.data
  } catch (error) {
    console.error('加载每日挑战失败:', error)
  }
}

const loadThemeProgress = async () => {
  try {
    const response = await getLevelList()
    themeProgress.value = response.data
  } catch (error) {
    console.error('加载主题进度失败:', error)
  }
}

const loadWeeklyRanking = async () => {
  try {
    const response = await getLeaderboard()
    // 检查响应数据结构
    if (response && response.data) {
      if (response.data.items && Array.isArray(response.data.items)) {
        weeklyRanking.value = response.data.items
      } else if (Array.isArray(response.data)) {
        weeklyRanking.value = response.data
      } else {
        weeklyRanking.value = []
      }
    } else {
      weeklyRanking.value = []
    }
  } catch (error) {
    console.error('加载周排行榜失败:', error)
    weeklyRanking.value = []
  }
}

// 加载排行榜数据
const loadLeaderboardData = async () => {
  try {
    // 传递时间范围参数给API调用
    const response = await getLeaderboard(50, rankingPeriod.value)
    
    // 检查响应数据结构
    if (response && response.data) {
      if (response.data.items && Array.isArray(response.data.items)) {
        leaderboardData.value = response.data.items
      } else if (Array.isArray(response.data)) {
        leaderboardData.value = response.data
      } else {
        leaderboardData.value = []
      }
    } else {
      // 使用模拟数据，传递当前的rankingPeriod
      leaderboardData.value = generateMockLeaderboardData(rankingPeriod.value)
    }
  } catch (error) {
    console.error('加载排行榜数据失败:', error)
    // 使用模拟数据，传递当前的rankingPeriod
    leaderboardData.value = generateMockLeaderboardData(rankingPeriod.value)
  }
}

// 加载用户排名信息
const loadUserRank = async () => {
  try {
    // 传递时间范围参数给API调用
    const response = await getMyRank(rankingPeriod.value)
    if (response && response.data) {
      userRank.value = response.data
    }
  } catch (error) {
    console.error('加载用户排名信息失败:', error)
    // 使用模拟数据，根据不同的rankingPeriod提供不同的模拟排名
    const mockRanks = {
      week: { rank: 24, total_score: 2450 },
      month: { rank: 56, total_score: 8760 },
      total: { rank: 134, total_score: 28920 }
    }
    const rankData = mockRanks[rankingPeriod.value as keyof typeof mockRanks] || mockRanks.week
    
    userRank.value = {
      ...rankData,
      username: '环保爱好者',
      accuracy_rate: 0.87,
      average_time: 42
    }
  }
}

// 生成模拟排行榜数据
const generateMockLeaderboardData = (period: string) => {
  const mockData = []
  const usernames = ['环保达人', '绿色先锋', '低碳骑士', '自然守护者', '地球卫士', 
                     '绿色使者', '生态专家', '环保志愿者', '节能减排者', '可持续生活家',
                     '气候行动者', '环境卫士', '低碳生活家', '绿色未来', '环保先锋']
  
  // 根据不同时间范围设置不同的分数基数
  let scoreBase: number
  let scoreVariation: number
  
  switch (period) {
    case 'week':
      scoreBase = 1000
      scoreVariation = 200
      break
    case 'month':
      scoreBase = 5000
      scoreVariation = 800
      break
    case 'total':
      scoreBase = 20000
      scoreVariation = 3000
      break
    default:
      scoreBase = 1000
      scoreVariation = 200
  }
  
  for (let i = 0; i < 20; i++) {
    mockData.push({
      rank: i + 1,
      username: i < usernames.length ? usernames[i] : `环保爱好者${i + 1}`,
      accuracy_rate: 0.7 + Math.random() * 0.3, // 70%-100%
      average_time: Math.floor(10 + Math.random() * 50), // 10-60秒
      total_score: Math.floor(scoreBase - i * (scoreVariation / 10) + Math.random() * (scoreVariation / 5))
    })
  }
  
  return mockData
}

// 切换标签页
const switchTab = (tab: string) => {
  activeTab.value = tab
  // 如果切换到排行榜标签，加载排行榜数据
  if (tab === 'ranking') {
    loadLeaderboardData()
    loadUserRank()
  }
}

// 切换排行榜周期
const changeRankingPeriod = (period: string) => {
  rankingPeriod.value = period
  loadLeaderboardData()
  loadUserRank()
}

// 获取排行榜标题
const getRankingTitle = () => {
  switch (rankingPeriod.value) {
    case 'week':
      return '周'
    case 'month':
      return '月'
    case 'total':
      return '总'
    default:
      return '周'
  }
}

// 获取排名样式类
const getRankClass = (rank: number) => {
  if (rank <= 3) {
    return `rank-top-${rank}`
  } else if (rank <= 10) {
    return 'rank-top-ten'
  }
  return ''
}


const loadChallengeHistory = async () => {
  try {
    const response = await getUserStats()
    challengeHistory.value = response.data
  } catch (error) {
    console.error('加载挑战历史失败:', error)
  }
}

// 加载用户统计数据
const loadUserStats = async () => {
  try {
    const response = await getUserStats()
    if (response && response.data) {
      userStats.value = response.data
    }
  } catch (error) {
    console.error('加载用户统计数据失败:', error)
  }
}

// 生命周期
onMounted(() => {
  loadDailyChallenge()
  loadThemeProgress()
  loadWeeklyRanking()
  loadChallengeHistory()
  loadUserStats()
})
</script>

<style scoped>
.challenge-page {
  width: 100%;
  padding: 20px;
  box-sizing: border-box;
  animation: pageLoad 0.8s ease-out;
}

@keyframes pageLoad {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 添加过渡动画 */
.fade-enter-active, .fade-leave-active {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-enter, .fade-leave-to {
  opacity: 0;
  transform: translateX(20px);
}

/* 标签页导航 */
.tabs-nav {
  display: flex;
  background: white;
  border-radius: 15px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  overflow: hidden;
}

.tab-item {
  flex: 1;
  padding: 15px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
  color: #6c757d;
  position: relative;
  overflow: hidden;
}

.tab-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: #36b37e;
  transition: width 0.3s ease;
}

.tab-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(54, 179, 126, 0.08);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s ease;
  z-index: 0;
}

.tab-item:hover::before {
  transform: scaleX(1);
  transform-origin: left;
}

.tab-item:hover {
  background-color: transparent;
  transform: translateY(-1px);
}

.tab-item.active {
  background: linear-gradient(135deg, #36b37e 0%, #256a4e 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(54, 179, 126, 0.3);
  transform: translateY(-2px);
}

.tab-item.active::after {
  width: 100%;
}

/* 内容区域过渡动画 */
.content-fade-enter-active,
.content-fade-leave-active {
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.content-fade-enter-from {
  opacity: 0;
  transform: translateY(20px);
}

.content-fade-leave-to {
  opacity: 0;
  transform: translateY(-20px);
}

/* 顶部导航区 */
.top-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #36b37e 0%, #256a4e 100%);
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 30px;
  box-shadow: 0 8px 25px rgba(54, 179, 126, 0.3);
  box-sizing: border-box;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 15px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 1.8rem;
}

.brand-title {
  color: white;
  margin: 0;
  font-size: 1.8rem;
  font-weight: bold;
}

.rules-section {
  font-size: 1.5rem;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.3s;
}

.rules-section:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* 页面内容布局 */
.challenge-content {
  display: grid;
  grid-template-columns: 300px 1fr 250px;
  gap: 20px;
  width: 100%;
  box-sizing: border-box;
}

/* 左侧功能导航 */
.left-navigation {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.daily-challenge, .theme-adventure, .weekly-ranking {
  background: white;
  border-radius: 20px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  padding: 25px;
  box-sizing: border-box;
  border: 1px solid #f0f0f0;
  position: relative;
  overflow: hidden;
}

.daily-challenge::before, .theme-adventure::before, .weekly-ranking::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
}

.daily-challenge::before {
  background: linear-gradient(90deg, #ff8a5b 0%, #ff6b35 100%);
}

.theme-adventure::before {
  background: linear-gradient(90deg, #36b37e 0%, #256a4e 100%);
}

.weekly-ranking::before {
  background: linear-gradient(90deg, #6457a6 0%, #503a92 100%);
}

.challenge-header, .adventure-header, .ranking-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.challenge-header h2, .adventure-header h2, .ranking-header h2 {
  margin: 0;
  color: #2c3e50;
  font-size: 1.3rem;
}

.challenge-status p {
  margin: 0;
  color: #256a4e;
  font-weight: 600;
  font-size: 1.1rem;
  background: linear-gradient(135deg, #e9f7ef 0%, #d5f0e2 100%);
  padding: 8px 15px;
  border-radius: 20px;
  display: inline-block;
}

.adventure-progress {
  margin-top: 15px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
  font-size: 0.9rem;
  color: #6c757d;
}

.progress-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.progress-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar {
  flex: 1;
  height: 12px;
  background-color: #f0fdf4;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e8f5e9;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #36b37e, #256a4e);
  border-radius: 6px;
  transition: width 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: progressShine 2s infinite;
}

@keyframes progressShine {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

.stage-number {
  font-size: 0.9rem;
  font-weight: bold;
  color: #495057;
  min-width: 20px;
  text-align: center;
}

.reward-badge {
  font-size: 1.2rem;
}

.ranking-content p {
  margin: 0 0 15px 0;
  color: #6c757d;
  font-size: 0.9rem;
}

.top-rankers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.rank-item:last-child {
  border-bottom: none;
}

.rank-number {
  font-weight: bold;
  color: #36b37e;
  min-width: 20px;
  background: #f0fdf4;
  padding: 2px 6px;
  border-radius: 4px;
}

.rank-name {
  flex: 1;
  margin-left: 10px;
  color: #495057;
}

.rank-score {
  font-weight: bold;
  color: #256a4e;
}

/* 主互动区 */
.main-interaction {
  background: white;
  border-radius: 24px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  padding: 35px;
  box-sizing: border-box;
  border: 1px solid #e8f5e9;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.main-interaction::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(54, 179, 126, 0.1) 0%, transparent 70%);
  border-radius: 50%;
  transform: translate(30%, -30%);
}

.welcome-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

.welcome-text h2 {
  color: #1e293b;
  margin-top: 0;
  font-size: 1.8rem;
  font-weight: 700;
  animation: slideIn 0.8s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.welcome-text p {
  color: #475569;
  font-size: 1.1rem;
  line-height: 1.6;
  margin: 10px 0 0 0;
  font-weight: 400;
}

.user-challenge-section {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 15px;
  min-width: 200px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
}

.username {
  font-weight: 500;
  color: #2c3e50;
  font-size: 1.1rem;
}

.user-points {
  display: flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #e9f7ef 0%, #d5f0e2 100%);
  padding: 10px 18px;
  border-radius: 25px;
  box-shadow: 0 2px 8px rgba(54, 179, 126, 0.1);
}

.points-value {
  font-weight: bold;
  color: #36b37e;
  font-size: 1.1rem;
  animation: pulsePoints 2s ease-in-out infinite;
}

@keyframes pulsePoints {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.start-challenge-btn {
  background: linear-gradient(135deg, #36b37e 0%, #256a4e 100%);
  color: white;
  padding: 12px 25px;
  border-radius: 25px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(54, 179, 126, 0.3);
  white-space: nowrap;
  border: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  font-size: 1rem;
}

.start-challenge-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(54, 179, 126, 0.4);
}

.start-challenge-btn:active {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(54, 179, 126, 0.4);
}

.start-challenge-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
  z-index: -1;
}

.start-challenge-btn:active::after {
  width: 300px;
  height: 300px;
}

.start-challenge-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(54, 179, 126, 0.3);
}

/* 点击波纹效果 */
.start-challenge-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.start-challenge-btn:active::after {
  width: 300px;
  height: 300px;
}

.start-challenge-btn:hover {
  background: linear-gradient(135deg, #40c463 0%, #276749 100%);
  transform: scale(1.03) translateY(-2px);
  box-shadow: 0 6px 20px rgba(54, 179, 126, 0.4);
}

.challenge-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.feature-card {
  background: white;
  border-radius: 20px;
  padding: 25px;
  text-align: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  border: 1px solid #e8f5e9;
  position: relative;
  overflow: hidden;
  animation: featureCardAppear 0.5s ease-out;
  animation-fill-mode: both;
}

.feature-card:nth-child(1) {
  animation-delay: 0.2s;
}

.feature-card:nth-child(2) {
  animation-delay: 0.3s;
}

.feature-card:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes featureCardAppear {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #36b37e, #256a4e);
}

.feature-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
  border-color: #36b37e;
}

.feature-card:active {
  transform: translateY(-4px) scale(0.99);
  transition: transform 0.1s ease;
}

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #e9f7ef 0%, #d5f0e2 100%);
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 15px;
  color: #36b37e;
  box-shadow: 0 4px 10px rgba(54, 179, 126, 0.15);
}

.feature-card h3 {
  margin: 15px 0 10px 0;
  color: #2c3e50;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.feature-card p {
  margin: 0;
  color: #6c757d;
  font-size: 0.95rem;
  line-height: 1.6;
}

.challenge-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.stat-card {
  background: linear-gradient(135deg, #36b37e 0%, #256a4e 100%);
  border-radius: 20px;
  padding: 30px 25px;
  text-align: center;
  color: white;
  box-shadow: 0 12px 36px rgba(54, 179, 126, 0.35);
  position: relative;
  overflow: hidden;
  transform: perspective(1000px) rotateX(0deg);
  transition: transform 0.4s ease, box-shadow 0.4s ease;
  animation: cardSlideIn 0.6s ease-out;
  animation-fill-mode: both;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-card:nth-child(1) {
  animation-delay: 0.1s;
}

.stat-card:nth-child(2) {
  animation-delay: 0.2s;
}

.stat-card:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
}

.stat-card h3 {
  margin: 0 0 10px 0;
  font-size: 1.1rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: bold;
  margin: 0;
  animation: countUp 1.5s ease-out;
}

@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.stat-label {
  margin: 5px 0 0 0;
  font-size: 0.9rem;
  opacity: 0.9;
}

/* 排行榜侧边栏样式 */
.ranking-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ranking-filters h3 {
  margin-top: 0;
  color: #2c3e50;
  margin-bottom: 15px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-btn {
  padding: 10px 15px;
  border: 2px solid #e9ecef;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

.filter-btn:hover {
  border-color: #36b37e;
  color: #36b37e;
  transform: translateX(5px) translateY(-1px);
  box-shadow: 0 4px 12px rgba(54, 179, 126, 0.2);
}

.filter-btn.active {
  background: #36b37e;
  border-color: #36b37e;
  color: white;
  box-shadow: 0 2px 8px rgba(54, 179, 126, 0.3);
}

.filter-btn:active {
  transform: translateX(3px) translateY(0);
}

.user-rank-info {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 15px;
}

.user-rank-info h3 {
  margin-top: 0;
  margin-bottom: 15px;
  color: #2c3e50;
}

.my-rank-item {
  display: flex;
  align-items: center;
  gap: 15px;
  background: white;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.my-rank-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.my-rank-detail .avatar {
  font-size: 2rem;
  margin-bottom: 5px;
}

.rank-info {
  display: flex;
  gap: 15px;
  font-size: 0.85rem;
  color: #6c757d;
  margin-top: 5px;
}

.rank-top-1 {
  color: #ffd700;
  font-size: 1.5rem;
  font-weight: bold;
}

.rank-top-2 {
  color: #c0c0c0;
  font-size: 1.5rem;
  font-weight: bold;
}

.rank-top-3 {
  color: #cd7f32;
  font-size: 1.5rem;
  font-weight: bold;
}

.rank-top-ten {
  color: #42b983;
  font-size: 1.2rem;
  font-weight: bold;
}

.no-data {
  text-align: center;
  color: #6c757d;
  padding: 20px;
  background: white;
  border-radius: 8px;
}

/* 排行榜主内容样式 */
.ranking-main-content {
  width: 100%;
}

.ranking-header-section {
  text-align: center;
  margin-bottom: 30px;
}

.ranking-header-section h2 {
  color: #2c3e50;
  margin-bottom: 10px;
}

.ranking-header-section p {
  color: #6c757d;
  margin: 0;
}

/* 前三名展示 */
.top-three-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 30px;
  margin-bottom: 40px;
  animation: podiumLoad 0.8s ease-out;
}

@keyframes podiumLoad {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.rank-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: white;
  border-radius: 20px;
  padding: 25px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  width: 180px;
  position: relative;
  overflow: hidden;
  transform: perspective(1000px) rotateX(5deg);
  transition: transform 0.4s ease;
}

.rank-item:hover {
  transform: perspective(1000px) rotateX(0deg) translateY(-10px);
}

.first-place {
  transform: translateY(-20px);
  border: 3px solid #ffd700;
  animation: firstPlaceGlow 2s ease-in-out infinite alternate;
}

.second-place {
  transform: translateY(-10px);
  border: 3px solid #c0c0c0;
  animation: secondPlaceGlow 2s ease-in-out infinite alternate 0.2s;
}

.third-place {
  border: 3px solid #cd7f32;
  animation: thirdPlaceGlow 2s ease-in-out infinite alternate 0.4s;
}

@keyframes firstPlaceGlow {
  from {
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
    border-color: #ffd700;
  }
  to {
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
    border-color: #ffec6e;
  }
}

@keyframes secondPlaceGlow {
  from {
    box-shadow: 0 0 15px rgba(192, 192, 192, 0.3);
    border-color: #c0c0c0;
  }
  to {
    box-shadow: 0 0 25px rgba(192, 192, 192, 0.6);
    border-color: #d8d8d8;
  }
}

@keyframes thirdPlaceGlow {
  from {
    box-shadow: 0 0 15px rgba(205, 127, 50, 0.3);
    border-color: #cd7f32;
  }
  to {
    box-shadow: 0 0 25px rgba(205, 127, 50, 0.6);
    border-color: #e69858;
  }
}

.medal {
  font-size: 2.5rem;
  margin-bottom: 10px;
  animation: medalFloat 2s ease-in-out infinite alternate;
}

@keyframes medalFloat {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-5px) scale(1.05);
  }
}

/* 排行榜列表 */
.ranking-list {
  background: white;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  animation: listLoad 0.6s ease-out;
}

@keyframes listLoad {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.ranking-list-header {
  display: grid;
  grid-template-columns: 80px 1fr 100px 100px 80px;
  background: linear-gradient(135deg, #36b37e 0%, #256a4e 100%);
  color: white;
  padding: 15px 20px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(54, 179, 126, 0.2);
}

.ranking-list-item {
  display: grid;
  grid-template-columns: 80px 1fr 100px 100px 80px;
  padding: 15px 20px;
  border-bottom: 1px solid #eee;
  align-items: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  animation: rankingItemSlideIn 0.4s ease-out;
  animation-fill-mode: both;
}

.ranking-list-item:hover {
  transform: translateX(5px);
  background-color: #f8f9fa;
  border-radius: 12px;
}

.ranking-list-item:active {
  transform: translateX(2px);
  transition: transform 0.1s ease;
}

.ranking-list-item:nth-child(even) {
  animation-delay: 0.1s;
}

@keyframes rankingItemSlideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.ranking-list-item::before {
  content: '';
  position: absolute;
  left: -100%;
  top: 0;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(54, 179, 126, 0.15), transparent);
  transition: left 0.6s ease;
}

.ranking-list-item:hover {
  background-color: #f8f9fa;
  transform: translateX(8px) translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.ranking-list-item:hover::before {
  left: 150%;
}

.ranking-list-item:active {
  transform: translateX(3px) translateY(0);
}

.ranking-list-item.my-rank {
  background: linear-gradient(90deg, #e9f7ef 0%, #f8fff9 100%);
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(54, 179, 126, 0.2);
  animation: highlightMyRank 1.5s ease-in-out infinite;
}

@keyframes highlightMyRank {
  0% {
    box-shadow: 0 6px 16px rgba(54, 179, 126, 0.2);
  }
  50% {
    box-shadow: 0 8px 20px rgba(54, 179, 126, 0.3);
  }
  100% {
    box-shadow: 0 6px 16px rgba(54, 179, 126, 0.2);
  }
}

@keyframes highlightRank {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 12px rgba(54, 179, 126, 0.15);
  }
  50% {
    transform: scale(1.01);
    box-shadow: 0 6px 18px rgba(54, 179, 126, 0.2);
  }
}

.ranking-list-item:last-child {
  border-bottom: none;
}

/* 添加排名数字的微交互 */
.rank-number {
  font-weight: bold;
  transition: transform 0.3s ease;
}

.ranking-list-item:hover .rank-number {
  transform: scale(1.1);
}

/* 用户头像悬停效果 */
.user-col .avatar {
  transition: transform 0.3s ease;
}

.ranking-list-item:hover .user-col .avatar {
  transform: scale(1.1) rotate(5deg);
}

/* 分数和进度微交互 */
.score-col, .progress-col {
  position: relative;
}

.score-value {
  transition: transform 0.3s ease;
}

.ranking-list-item:hover .score-value {
  transform: scale(1.1);
  font-weight: bold;
}

.user-col {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 排行榜右侧信息 */
.ranking-right-info {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ranking-rules {
  background: white;
  border-radius: 20px;
  padding: 25px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border: 1px solid #e8f5e9;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.ranking-rules::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #36b37e, #256a4e);
}

.ranking-rules:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.ranking-rules h3 {
  margin-top: 0;
  color: #2c3e50;
  margin-bottom: 15px;
  transition: color 0.3s ease;
}

.ranking-rules:hover h3 {
  color: #36b37e;
}

.ranking-rules ul {
  margin: 0;
  padding-left: 20px;
  color: #6c757d;
  transition: color 0.3s ease;
}

.ranking-rules:hover li {
  color: #2c3e50;
}

.ranking-rules li {
  margin-bottom: 8px;
  line-height: 1.5;
}

.ranking-rules, .ranking-rewards {
  background: white;
  border-radius: 20px;
  padding: 25px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  border: 1px solid #f0f0f0;
  position: relative;
  overflow: hidden;
}

.ranking-rules::before, .ranking-rewards::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #6457a6 0%, #503a92 100%);
}

.ranking-rewards h3 {
  margin-top: 0;
  color: #2c3e50;
  margin-bottom: 15px;
}

.reward-tier {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 0;
  border-bottom: 1px solid #eee;
  transition: all 0.3s ease;
  border-radius: 8px;
}

.reward-tier:hover {
  background-color: #f8f9fa;
  padding-left: 10px;
  transform: translateX(5px);
}

.reward-tier:last-child {
  border-bottom: none;
}

.tier-icon {
  font-size: 1.5rem;
  width: 40px;
  text-align: center;
}

.tier-title {
  font-weight: 500;
  color: #2c3e50;
}

.tier-reward {
  color: #6c757d;
  font-size: 0.9rem;
}

/* 右侧信息激励区 */
.right-info {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.personal-data, .popular-recommendations, .point-redemption {
  background: white;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 25px;
  box-sizing: border-box;
  border: 1px solid #e8f5e9;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.personal-data::before, .popular-recommendations::before, .point-redemption::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
}

.personal-data::before {
  background: linear-gradient(90deg, #36b37e 0%, #256a4e 100%);
}

.popular-recommendations::before {
  background: linear-gradient(90deg, #ff8a5b 0%, #ff6b35 100%);
}

.point-redemption::before {
  background: linear-gradient(90deg, #6457a6 0%, #503a92 100%);
}

/* 卡片通用悬停效果 */
.personal-data:hover, .popular-recommendations:hover, .point-redemption:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

/* 个人数据卡片特效 */
.personal-data {
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.personal-data::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 100%;
  background: linear-gradient(135deg, rgba(54, 179, 126, 0.05), transparent);
  transition: width 0.5s ease;
}

.personal-data:hover::after {
  width: 100%;
}

/* 数据项微交互 */
.data-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
  transition: all 0.3s ease;
  position: relative;
}

.data-item::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #36b37e, transparent);
  transition: width 0.3s ease;
}

.data-item:hover {
  transform: translateX(8px);
}

.data-item:hover::after {
  width: 100%;
}

.data-item:last-child {
  border-bottom: none;
}

.data-item:last-child::after {
  display: none;
}

.data-item:hover span:last-child {
  color: #256a4e;
  transform: scale(1.1) translateY(-2px);
}

.data-item span:first-child {
  transition: color 0.3s ease;
}

.data-item:hover span:first-child {
  color: #36b37e;
  font-weight: 600;
}

.data-item span:last-child {
  font-weight: bold;
  color: #42b983;
  transition: all 0.3s ease;
}

/* 标题悬停效果 */
.personal-data h3, .popular-recommendations h3, .point-redemption h3 {
  margin-top: 0;
  color: #2c3e50;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
  transition: color 0.3s ease;
}

.personal-data:hover h3 {
  color: #36b37e;
}

.popular-recommendations:hover h3 {
  color: #ff6b35;
}

.point-redemption:hover h3 {
  color: #6457a6;
}

/* 推荐和兑换项微交互 */
.recommendation-item, .redemption-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 0;
  border-bottom: 1px solid #eee;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.recommendation-item::before, .redemption-item::before {
  content: '';
  position: absolute;
  left: -100%;
  top: 0;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
  transition: left 0.6s ease;
}

.recommendation-item:hover::before, .redemption-item:hover::before {
  left: 150%;
}

.recommendation-item:hover {
  transform: translateX(10px) translateY(-2px);
  background-color: #fff5e6;
  padding-left: 10px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.1);
}

.redemption-item:hover {
  transform: translateX(10px) translateY(-2px);
  background-color: #f5f0ff;
  padding-left: 10px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(100, 87, 166, 0.1);
}

.recommendation-item:active, .redemption-item:active {
  transform: translateX(5px) translateY(0);
}

.recommendation-item:last-child, .redemption-item:last-child {
  border-bottom: none;
}

/* 图标悬停效果 */
.recommendation-icon, .redemption-icon {
  font-size: 1.5rem;
  transition: all 0.3s ease;
}

.recommendation-item:hover .recommendation-icon {
  transform: scale(1.2) rotate(10deg);
  color: #ff6b35;
}

.redemption-item:hover .redemption-icon {
  transform: scale(1.2) rotate(10deg);
  color: #6457a6;
}

/* 内容悬停效果 */
.recommendation-content h4, .redemption-content h4 {
  margin: 0 0 5px 0;
  color: #2c3e50;
  transition: color 0.3s ease;
}

.recommendation-item:hover .recommendation-content h4 {
  color: #ff6b35;
  transform: translateX(5px);
}

.redemption-item:hover .redemption-content h4 {
  color: #6457a6;
  transform: translateX(5px);
}

.recommendation-content p, .redemption-content p {
  margin: 0;
  color: #6c757d;
  transition: color 0.3s ease;
}

.recommendation-item:hover .recommendation-content p,
.redemption-item:hover .redemption-content p {
  color: #2c3e50;
}

.recommendation-icon, .redemption-icon {
  font-size: 1.5rem;
}

.recommendation-content h4, .redemption-content h4 {
  margin: 0 0 5px 0;
  color: #2c3e50;
}

.recommendation-content p, .redemption-content p {
  margin: 0;
  color: #6c757d;
  font-size: 0.9rem;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .challenge-content {
    grid-template-columns: 220px 1fr 180px;
  }
  
  .brand-title {
    font-size: 1.4rem;
  }
  
  .challenge-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .feature-card {
    padding: 20px;
  }
  
  .feature-icon {
    width: 60px;
    height: 60px;
    font-size: 2rem;
  }
  
  /* 排行榜响应式 */
  .ranking-list-header,
  .ranking-list-item {
    grid-template-columns: 60px 1fr 80px 80px 60px;
    padding: 12px 15px;
  }
  
  .rank-item {
    width: 150px;
    padding: 20px;
  }
  
  .main-interaction {
    padding: 30px 25px;
  }
}

@media (max-width: 992px) {
  .challenge-content {
    grid-template-columns: 1fr;
  }
  
  .top-navigation {
    flex-wrap: wrap;
    gap: 15px;
  }
  
  .user-section {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  
  .challenge-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .welcome-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .user-challenge-section {
    align-items: flex-start;
    width: 100%;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
  }
  
  .challenge-features {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* 排行榜响应式 */
  .top-three-container {
    flex-wrap: wrap;
    gap: 20px;
  }
  
  .rank-item {
    width: calc(50% - 20px);
    min-width: 150px;
  }
  
  .ranking-sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
  
  .ranking-main-content {
    margin-top: 20px;
  }
  
  .ranking-list-header,
  .ranking-list-item {
    grid-template-columns: 50px 1fr 70px 70px 50px;
    font-size: 0.9rem;
  }
}

/* 平板和小型平板设备优化 */
@media (max-width: 768px) {
  .challenge-page {
    padding: 15px;
  }
  
  .top-navigation {
    padding: 15px;
  }
  
  .brand-logo {
    font-size: 1.5rem;
  }
  
  .brand-title {
    font-size: 1.3rem;
  }
  
  .tab-item {
    padding: 12px 15px;
    font-size: 0.95rem;
  }
  
  .start-challenge-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
    width: 100%;
    text-align: center;
  }
  
  .challenge-content {
    gap: 15px;
  }
  
  .main-interaction {
    padding: 25px 20px;
    border-radius: 20px;
  }
  
  .welcome-text h2 {
    font-size: 1.5rem;
  }
  
  .welcome-text p {
    font-size: 1rem;
  }
  
  .challenge-stats {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .challenge-features {
    grid-template-columns: 1fr;
  }
  
  .feature-card {
    padding: 20px 15px;
  }
  
  .progress-item {
    gap: 5px;
  }
  
  .stage-number {
    font-size: 0.8rem;
  }
  
  /* 排行榜响应式 */
  .rank-item {
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
  }
  
  .ranking-sidebar {
    grid-template-columns: 1fr;
  }
  
  .ranking-list-header,
  .ranking-list-item {
    grid-template-columns: 40px 1fr;
    font-size: 0.85rem;
  }
  
  .ranking-list-header > div:nth-child(n+3),
  .ranking-list-item > div:nth-child(n+3) {
    display: none;
  }
}

/* 手机设备优化 */
@media (max-width: 480px) {
  .challenge-page {
    padding: 10px;
  }
  
  .top-navigation {
    padding: 10px;
  }
  
  .brand-section {
    gap: 10px;
  }
  
  .brand-logo {
    font-size: 1.3rem;
  }
  
  .brand-title {
    font-size: 1.1rem;
  }
  
  .user-points {
    padding: 3px 10px;
    font-size: 0.9rem;
  }
  
  .tab-item {
    padding: 10px 12px;
    font-size: 0.9rem;
  }
  
  .start-challenge-btn {
    padding: 8px 15px;
    font-size: 0.8rem;
    width: 100%;
    text-align: center;
  }
  
  .challenge-content {
    gap: 10px;
  }
  
  .main-interaction {
    padding: 15px;
    border-radius: 16px;
  }
  
  .welcome-text h2 {
    font-size: 1.3rem;
  }
  
  .welcome-text p {
    font-size: 0.95rem;
  }
  
  .daily-challenge, .theme-adventure, .weekly-ranking {
    padding: 20px 15px;
    border-radius: 16px;
  }
  
  .rules-section {
    font-size: 1.2rem;
  }
  
  .stat-card {
    padding: 15px;
    border-radius: 16px;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }
  
  .feature-card {
    padding: 15px;
  }
  
  .feature-icon {
    width: 50px;
    height: 50px;
    font-size: 1.8rem;
  }
  
  .progress-bar {
    height: 8px;
  }
  
  /* 排行榜响应式 */
  .top-three-container {
    gap: 15px;
    margin-bottom: 30px;
  }
  
  .rank-item {
    width: 100%;
    max-width: 150px;
    padding: 15px;
  }
  
  .medal {
    font-size: 2rem;
  }
}

@media (max-width: 992px) {
  .challenge-content {
    grid-template-columns: 1fr;
  }
  
  .top-navigation {
    flex-wrap: wrap;
    gap: 15px;
  }
  
  .user-section {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  
  .challenge-stats {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .welcome-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .user-challenge-section {
    align-items: flex-start;
    width: 100%;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
  }
}

@media (max-width: 768px) {
  .challenge-page {
    padding: 15px;
  }
  
  .top-navigation {
    padding: 15px;
  }
  
  .brand-logo {
    font-size: 1.5rem;
  }
  
  .brand-title {
    font-size: 1.3rem;
  }
  
  .start-challenge-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }
  
  .challenge-content {
    gap: 15px;
  }
  
  .main-interaction {
    padding: 20px;
  }
  
  .welcome-text h2 {
    font-size: 1.5rem;
  }
  
  .challenge-stats {
    grid-template-columns: 1fr;
  }
  
  .progress-item {
    gap: 5px;
  }
  
  .stage-number {
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .top-navigation {
    padding: 10px;
  }
  
  .brand-section {
    gap: 10px;
  }
  
  .brand-title {
    font-size: 1.1rem;
  }
  
  .user-points {
    padding: 3px 10px;
    font-size: 0.9rem;
  }
  
  .start-challenge-btn {
    padding: 8px 15px;
    font-size: 0.8rem;
  }
  
  .challenge-content {
    gap: 10px;
  }
  
  .main-interaction {
    padding: 15px;
  }
  
  .welcome-text h2 {
    font-size: 1.3rem;
  }
  
  .feature-card {
    padding: 15px;
  }
  
  .feature-icon {
    font-size: 2rem;
  }
  
  .stat-card {
    padding: 15px;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }
}
</style>